<html>
	<head>
    	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    </head>
	<body>
    	<?php
			if(isset($_REQUEST["height"],$_REQUEST["width"])){
					$height = $_REQUEST["height"];
					$width = $_REQUEST["width"];
					$type = $_REQUEST["type"];
					}
                ?>
    	<form action="firkantregner.php">
            <table border="1">
                <tr>
                    <th>Højde</th>
                    <td>
                        <input type="text" name="height" value="<?php if(isset($height)){ echo $height;} ?>" />
                    </td>
				</tr>
                <tr>
                	<th>Bredde</th>
                    <td>
                    	<input type="text" name="width" value="<?php if(isset($width)){ echo $width;} ?>"/>
					</td>
              	</tr>
                <tr>
                	<td colspan="2">
                    	<input type="radio" name="type" value="o" <?php if(isset($type) && $type == "o"){ echo "checked";} ?> checked />Omkreds<br />
                        <input type="radio" name="type" value="a" <?php if(isset($type) && $type == "a"){ echo "checked";} ?>/>Areal<br />
                        <input type="radio" name="type" value="d" <?php if(isset($type) && $type == "d"){ echo "checked";} ?>/>Diagonal
					</td>
				</tr>
                <tr>
                	<td>
                    	<input type="submit" value="Beregn"/>
					</td>
    	<?php
			if(isset($type)){
				if($type == "o"){
					$total = 2*$height + 2*$width;
				}
				if($type == "a"){
					$total = $height*$width;
				}
				if($type == "d"){
					$total = sqrt($height*$height + $width*$width);
				}
				echo "<td>$total</td></tr></table>";
					
			}
		?>
        <footer>&copy; Frederik Mattern</footer>
	</body>
</html>